<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 200px;
            height: 200px;
            background-color: blue;
        }
        .inner{
            width: 100px;
            height: 100px;
            background-color: red;
        }
        .insert{
            width: 50px;
            height: 50px;
            background-color: orange;
        } 
    </style>
</head>
<body>
    <div class="box">
        <div class="inner d1">
            <div class="insert d1"></div>
        </div>
    </div>

    <script>
        var box = document.querySelector('.box');
        var inner = document.querySelector('.inner');
        var insert = document.querySelector('.insert');

        console.log(insert.closest('.box'));
        console.log(insert.closest('div div'));
        console.log(insert.closest('.d1'));
    </script>
</body>
</html>